######################################
# target
######################################
TARGET = test
BUILD_DIR = build
LVGL_DIR = C:/Users/lee/Documents/los/3rd/lvgl
DEMO_DIR = C:/Users/lee/Documents/los/test/lvgl/src
C_SOURCES  = test.c
C_SOURCES +=$(LVGL_DIR)/src/lv_themes/lv_theme.c
C_SOURCES +=$(LVGL_DIR)/src/lv_themes/lv_theme_material.c
C_SOURCES +=$(LVGL_DIR)/src/lv_themes/lv_theme_mono.c
C_SOURCES +=$(LVGL_DIR)/src/lv_themes/lv_theme_empty.c
C_SOURCES +=$(LVGL_DIR)/src/lv_themes/lv_theme_template.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_arc.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_bar.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_checkbox.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_cpicker.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_dropdown.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_keyboard.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_line.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_msgbox.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_spinner.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_roller.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_table.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_tabview.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_tileview.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_btn.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_calendar.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_chart.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_canvas.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_gauge.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_label.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_list.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_slider.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_textarea.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_spinbox.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_btnmatrix.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_cont.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_img.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_imgbtn.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_led.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_linemeter.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_page.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_switch.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_win.c
C_SOURCES +=$(LVGL_DIR)/src/lv_widgets/lv_objmask.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_group.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_indev.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_disp.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_obj.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_refr.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_style.c
C_SOURCES +=$(LVGL_DIR)/src/lv_core/lv_debug.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_mask.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_blend.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_rect.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_label.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_line.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_img.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_arc.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_draw_triangle.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_img_decoder.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_img_cache.c
C_SOURCES +=$(LVGL_DIR)/src/lv_draw/lv_img_buf.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_fmt_txt.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_12.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_14.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_16.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_18.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_20.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_22.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_24.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_26.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_28.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_30.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_32.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_34.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_36.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_38.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_40.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_42.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_44.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_46.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_48.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_12_subpx.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_montserrat_28_compressed.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_unscii_8.c
C_SOURCES +=$(LVGL_DIR)/src/lv_font/lv_font_dejavu_16_persian_hebrew.c
C_SOURCES +=$(LVGL_DIR)/src/lv_gpu/lv_gpu_stm32_dma2d.c
C_SOURCES +=$(LVGL_DIR)/src/lv_hal/lv_hal_disp.c
C_SOURCES +=$(LVGL_DIR)/src/lv_hal/lv_hal_indev.c
C_SOURCES +=$(LVGL_DIR)/src/lv_hal/lv_hal_tick.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_area.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_task.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_fs.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_anim.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_mem.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_ll.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_color.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_txt.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_txt_ap.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_math.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_log.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_gc.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_utils.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_async.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_printf.c
C_SOURCES +=$(LVGL_DIR)/src/lv_misc/lv_bidi.c

C_SOURCES +=$(DEMO_DIR)/lv_demo_keypad_encoder/lv_demo_keypad_encoder.c

C_SOURCES +=$(DEMO_DIR)/lv_demo_stress/lv_demo_stress.c

C_SOURCES +=$(DEMO_DIR)/lv_demo_benchmark/lv_demo_benchmark.c

C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/lv_demo_printer.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/lv_demo_printer_theme.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_bright.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_eco.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_hue.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_pc.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_tel.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_icon_wifi.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_btn_bg_1.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_btn_bg_2.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_btn_bg_3.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_btn_bg_4.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_cloud.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_copy.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_internet.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_mobile.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_no_internet.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_phone.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_print.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_printer2.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_ready.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_scan.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_scan_example.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_setup.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_usb.c
C_SOURCES +=$(DEMO_DIR)/lv_demo_printer/images/lv_demo_printer_img_wave.c

# C defines  -DFREERTOS 
C_DEFS = #-DLV_CONF_INCLUDE_SIMPLE

OPT = -O0

C_INCLUDES		=  \
-I. \
-I$(LVGL_DIR)/src/lv_misc \
-I$(LVGL_DIR)/src/lv_hal \
-I$(LVGL_DIR)/src/lv_themes \
-I$(LVGL_DIR)/src/lv_widgets \
-I$(LVGL_DIR)/src/lv_core \
-I$(LVGL_DIR)/src/lv_draw \
-I$(LVGL_DIR)/src/lv_font \
-I$(LVGL_DIR)/src/lv_gpu \
-I$(LVGL_DIR)/src \
-I$(LVGL_DIR) \
-I$(DEMO_DIR)/lv_demo_printer \
-I$(DEMO_DIR)/lv_demo_keypad_encoder \
-I$(DEMO_DIR)/lv_demo_stress \
-I$(DEMO_DIR)/lv_demo_benchmark \
-IC:/Users/lee/Documents/los/test/lvgl/src \
-IC:/Users/lee/Documents/los/test/lvgl
#######################################
# binaries
#######################################
#PREFIX = C:/Users/lee/Videos/LLVM/bin/
#Release  Debug
PREFIX = C:/Users/lee/Documents/los-llvm-build/Release/bin/
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.

##CC = gcc
CC = $(PREFIX)clang.exe
CP = $(PREFIX)llvm-objcopy


CFLAGS =  -std=c99 $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -c -fmessage-length=0

# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
 
# libraries
LIBS = -lc
LIBDIR = 
LDFLAGS =   $(LIBDIR) $(LIBS)  -Wl,--gc-sections 
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map
##

# default action: build all
all: $(TARGET).out

#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
	$(CC) -c $(CFLAGS)  $< -o $@

$(TARGET).out: $(OBJECTS) Makefile
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(CP) -O binary $(TARGET).out $(TARGET).los

$(BUILD_DIR):
	mkdir $@

#######################################
# clean up
#######################################
clean:
	-rm -fR $(BUILD_DIR)
  
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***
